// main_init function

main_init = function(mc){
 shape = function(mc,x0,y0,x1,y1,x2,y2,x3,y3){
  mc.lineStyle();
  mc.beginFill(0);
  mc.moveTo(x0,y0);
  mc.lineTo(x1,y1);
  mc.lineTo(x2,y2);
  mc.lineTo(x3,y3);
  mc.endFill();
 }
 subs_done = true;
 b = mc.getBounds(mc);
 dx = (b.yMax-b.yMin)/Math.tan(bar_angle*Math.PI/180);
 bars = Math.ceil((b.xMax-b.xMin+Math.abs(dx))/bar_size);
 for (i=0; i<bars; i++){
  mc.duplicateMovieClip("s"+i,9+i,{frame:0,offset:i*sub_delay,done:false});
  createEmptyMovieClip("sm"+i,9+bars+i);
  var sm = this["sm"+i];
  var s = this["s"+i];
  cur_angle = i % 2 ? angle : angle + 180;
  s.ix = s._x; s.ox = s._x + Math.cos(cur_angle*Math.PI/180)*distance;
  s.iy = s._y; s.oy = s._y - Math.sin(cur_angle*Math.PI/180)*distance;
  o = i*bar_size;
  if (dx>0){
   shape(sm,o+b.xMin,b.yMin, o+b.xMin+bar_size,b.yMin, o+b.xMin-dx+bar_size,b.yMax, o+b.xMin-dx,b.yMax);
  } else {
   shape(sm,o+b.xMin+dx,b.yMin, o+b.xMin+dx+bar_size,b.yMin, o+b.xMin+bar_size,b.yMax, o+b.xMin,b.yMax);
  }
  s.setMask(sm);
  if (!out_effect){
   s._x = sm._x = s.ox;
   s._y = sm._y = s.oy;
   if (fade) s._alpha = 0;
  }
  for(m in s) if (!s[m].hitTest(sm)){
   s[m].swapDepths(1);
   s[m].removeMovieClip();
  }
 }
 mc._alpha = 0;
}

// main_effect function

main_effect = function(mc,frame){
 for(i=0; i<bars; i++){
  var sm = this["sm"+i];
  var s = this["s"+i];
  if (frame>s.offset && !s.done){
   perc = (frame-s.offset) / lastsubframe;
   if (perc == 1){
    s.done = true;
    if (i == bars-1){
     for (j=0; j<bars; j++){
      this["sm"+j].removeMovieClip();
      this["s"+j].removeMovieClip();
     }
     if (!out_effect) mc._alpha = 100;
     end_effect = true;
    }
   }
   perc = linear_speed ? 1-perc : 1-Math.sin(perc*deg90);
   if (out_effect) perc = 1-perc;
   if (fade) s._alpha=100-perc*100;
   sm._x = s._x = perc * s.ox + s.ix - perc * s.ix;
   sm._y = s._y = perc * s.oy + s.iy - perc * s.iy;
  }
 }
}

// sub_init function

sub_init = function(mc){
}

// sub_effect function

sub_effect = function(mc,frame){
}
